package com.mercury.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mercury.user.entity.CenterUserTasted;
import com.mercury.user.mapper.CenterUserTastedMapper;
import com.mercury.user.service.CenterUserTastedService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author tong
 * @since 2021-11-14
 */
@Service
public class CenterUserTastedServiceImpl extends ServiceImpl<CenterUserTastedMapper, CenterUserTasted> implements CenterUserTastedService {



    @Override
    public int getCount(String userId) {
        QueryWrapper<CenterUserTasted> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id", userId);
        Integer count = baseMapper.selectCount(wrapper);
        return count;
    }

    /**
     * @date 2021/11/22 8:32
     * @params userId
     * @return
     * @description 根据用户的 id 获得他喝过的 coffee id
    */
    @Override
    public List<CenterUserTasted> getUserTasted(String userId) {
        QueryWrapper<CenterUserTasted> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId);
        List<CenterUserTasted> tastedList = baseMapper.selectList(wrapper);
        return tastedList;
    }

}
